<?php
require_once('../phplib/include.inc.php');

class Home_Train extends PageBase{
	public function Ini(){
		$this->GetTrains();
		$this->GetInfo();
		$this->GetContactInfo();
		$this->IsAdministratorOnline();
	}
	public function GetTrains(){
		$db = getDb();
		$re = $db->fetch("SELECT b.cat_name,a.a_id,a.a_title,a.a_time,a.a_visit FROM article AS a LEFT JOIN category AS b ON a.c_id=b.c_id WHERE a.a_del=0 AND b.cat_name='嵌入式培训' ORDER BY a.a_id DESC");
		$this->assign("trains",$re);
	}
	public function GetInfo(){
		$db = getDb();
		$re = $db->fetchOne("SELECT * FROM subhome WHERE s_name='嵌入式培训'");
		$this->assign('subhomeinfo',$re);
	}
	public function GetContactInfo(){
		$db = getDb();
		$re = $db->fetchOne("SELECT * FROM subhome WHERE s_name='联系信息'");
		$this->assign("contactinfo",unserialize($re['s_content']));
	}
	public function IsAdministratorOnline(){
		$db = getDb();
		$re = $db->fetch("SELECT * FROM online WHERE o_type=1 AND o_time>".(time() - 60 * 2));
		$this->assign('admin_online',count($re));
	}
}
$a = new Home_Train("file:".dirname(__FILE__)."/../home/train.tpl.html");
$a->display();
?>